﻿if (typeof window.WechatConfig !== "undefined") {
    try {
        window.WechatConfig.config({
            'pic': 'https://cdn-df.00bang.net/images/T1xtWTBKAT1RCvBVdK.jpg', //分享图片地址
            'title': '惊不惊喜，意不意外？510元送给你', //分享标题
            'desc': '4.28万起，大空间多功能家轿宝骏310W震撼上市！', //分享描述
            'link': 'http://app-wuling-cooperation.app.weixinhost.com/index.html?openid=' + llb_global.utils.readcookie("openid"),
            'appid': 'wx7fff11837244a6db',
            'hide_menu': false,
            'debug': false
        });
        window.WechatConfig.init();
        window.WechatConfig.on('ready',
            function () {
                window.WechatConfig.on('shareTimeline',
                    function () {
                        var a = window.WechatConfig._event['shareTimeline'];
                        if (typeof a === "function") {
                            a();
                        }
                    });
                // window.WechatConfig.updateConfig();
            });
    } catch (e) {

    }
}

$(function () {
    var inviteOpenid = llb_global.utils.getQueryString("openid") || "";
    $.ajax({
        type: "POST",
        url: llb_global.config.wxapi + "ajax_be_invite",
        data: JSON.stringify({ "creator": inviteOpenid }),
        dataType: "json",
        xhrFields: {
            withCredentials: true
        },
        success: function (res) {
        },
        error: function (e) { }
    });
    //邀请关系需要自己维护
    var inviteInfo = { openid: "", mobile: "" };
   
    if (inviteOpenid.length > 0) {
        inviteInfo.openid = inviteOpenid;
        $.ajax({
            type: "GET",
            url: llb_global.config.wxapi + "ajax_h5_get_user_info",
            data: { openid: inviteInfo.openid },
            xhrFields: {
                withCredentials: true
            },
            success: function (data) {
                if (data.err_code == 0) {
                    if (typeof (data.data.mobile) !== "undefined") {
                        inviteInfo.mobile = data.data.mobile;
                        llb_global.utils.setCookie("inviteInfo", JSON.stringify(inviteInfo));
                    }
                }
            },
            error: function (e) {
               // alert("userinfo data:" + JSON.stringify(e));
            }
        });
    }
});



